package com.woniuxy.his.controller;


import com.woniuxy.his.common.Result;
import com.woniuxy.his.controller.form.SetStatusForm;
import com.woniuxy.his.service.IPrescriptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 处方表 前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-08-25
 */
@RestController
@Slf4j
@CrossOrigin("*")
public class PrescriptionController {

    @Resource
    private IPrescriptionService prescriptionService;

    @PostMapping("outMedicineOk")
    public Result outMedicineOk(@RequestBody SetStatusForm setStatusForm){
        log.info("病人id信息:{}", setStatusForm);
        Integer num = prescriptionService.setIsGiveMedicineStatu(setStatusForm.getPrescriptionId());
        if (num==0) {
            return Result.fail("40000","修改失败",null);
        }
        return Result.success("20000","修改成功",null);
    }

    //修改药方缴费情况根据药方编号
    @PostMapping("medicinePay")
    public Result medicinePay(@RequestBody SetStatusForm setStatusForm){
        log.info("药方id：{}",setStatusForm);
        Integer i = prescriptionService.setIsPaidOfPrescription(setStatusForm.getPrescriptionId());
        if (i==0) {
            return Result.fail("20000","修改成功",null);
        }
        return Result.success("20000","修改成功",null);
    }



}

